package vn.personal.anhht.bloback12.activity;



import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class NotificationActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Intent intent = getIntent();

		sendNotify(intent.getStringExtra("NOTIFICATION_HEADER"),
				intent.getStringExtra("NOTIFICATION_TITLE"),
				intent.getStringExtra("NOTIFICATION_MESSAGE"));
		finish();
	}

	NotificationManager mNotManager;
	Notification mNotification;

	public void sendNotify(String header, String title, String message) {
		// get the notification manager
		mNotManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
		// create a notification
		mNotification = new Notification(R.drawable.ic_callblock_notification, header,
				System.currentTimeMillis());

		// Starting an intent

		Intent notIntent = new Intent(getApplicationContext(),
				NotificationActivity.class);
		notIntent.putExtra("NOTIFICATION_TITLE", title);
		notIntent.putExtra("NOTIFICATION_MESSAGE", message);

		PendingIntent StartIntent = PendingIntent.getActivity(
				getApplicationContext(), 2, notIntent, 0);

		// set the notification
		mNotification.setLatestEventInfo(getApplicationContext(), title,
				message, StartIntent);
		mNotification.ledOnMS = 200;
		mNotification.ledOffMS = 200;
		mNotification.ledARGB = 0x9400d3;

		// send notification to status bar
		mNotManager.notify(new java.util.Random().nextInt(Integer.MAX_VALUE),
				mNotification);
	}
}
